package core.inputoutput.formatting;

/**
 * This class takes a line of a PDB file and, based on the format in the constructor, transforms that line
 * into an "entry" which makes all components of that line easily accessable after the format parsing occurs
 * @author Julian
 *
 */
public abstract class FormattedEntry {

	/**
	 * Creates an entry from the line based on the format.
	 * @param line = input line
	 * @param f = Format of the PDB file
	 */
	public FormattedEntry(String line, Format f){
		int index = 0;
		int[] columnSizes = f.getColumnWidths();
		for (int col = 0; col < columnSizes.length ; col++){
			assignVal(line.substring(index, index+columnSizes[col]), col);
			index+=columnSizes[col];
		}
	}

	/**
	 * Assigns the value found in this column to some field/method in the Entry class
	 * @param substring = substring of line determines by postion and width of column
	 * @param colNum = column index 
	 */
	protected abstract void assignVal(String substring, int colNum);
	
}
